﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Teris
{
    enum E_DrawType
    { 
        Wall,
        Cube,
        Line,
        Tank,
        Left_Stair,
        Right_Stair,
        Left_Long_Stair,
        Right_Long_Stair
    }

    internal class DrawObject : IDraw
    {
        public Position pos;
        E_DrawType drawType;

        public DrawObject(E_DrawType DrawT)
        {
            drawType = DrawT;
        }

        public DrawObject(E_DrawType DrawT, int x, int y):this(DrawT)
        { 
            pos = new Position(x, y);
        }

        public void Draw()
        {
            if (pos.y < 0) return;

            Console.SetCursorPosition(pos.x, pos.y);
            SwitchColor();
            Console.Write("■");
        }

        public void ChangeType(E_DrawType t)
        {
            drawType = t;
        }

        void SwitchColor()
        {
            switch (drawType)
            {
                case E_DrawType.Wall:
                    Console.ForegroundColor = ConsoleColor.Red;
                    break;
                case E_DrawType.Cube:
                    Console.ForegroundColor = ConsoleColor.Blue;
                    break;
                case E_DrawType.Line:
                    Console.ForegroundColor = ConsoleColor.Green;
                    break;
                case E_DrawType.Tank:
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    break;
                case E_DrawType.Left_Stair:
                case E_DrawType.Right_Stair:
                    Console.ForegroundColor = ConsoleColor.Magenta;
                    break;
                case E_DrawType.Left_Long_Stair:
                case E_DrawType.Right_Long_Stair:
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    break;
            }

        }

        public void Clear()
        {
            if (pos.y < 0) return;

            Console.SetCursorPosition(pos.x, pos.y);
            Console.Write("  ");
        }
    }
}